package com.example.demo03.controller;

import com.example.demo03.enter.Luo;
import com.example.demo03.service.LuoService;
import com.example.demo03.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "扣扣空间")
@RequestMapping("/luo")
public class LuoC {
    @Autowired private LuoService LuoService;

    @ApiOperation(value = "查询",notes ="<span style='color:red;'>破军建武，正在今朝：</span>&nbsp;枫糖的家" )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "",value = "查询全部",required = false)
            })
    @GetMapping("/list")
    public R list(){
        return LuoService.selectAll();
    }

    @ApiOperation(value = "添加",notes ="<span style='color:red;'>长缨在手，敢缚苍龙：</span>&nbsp;枫糖的家" )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "ID",required = true),
            @ApiImplicitParam(name = "name",value = "用户姓名",required = true),
            @ApiImplicitParam(name = "sex",value = "用户性别",required = false)
    })
    @PostMapping("/add")
    public R add(Luo luo){
        return LuoService.add(luo);
    }

    @ApiOperation(value = "根据ID查询",notes ="<span style='color:red;'>对天起誓，以明我志：</span>&nbsp;枫糖的家" )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "ID",required = true),
    })
    @GetMapping("/ById")
    public R ById(Integer id){
        return LuoService.selectById(id);
    }
    @ApiOperation(value = "根据ID删除",notes ="<span style='color:red;'>翼展宏图，空留天妒：</span>&nbsp;枫糖的家" )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "ID",required = true),
    })
    @DeleteMapping("/delect")
    public R delect(Integer id){
        return LuoService.delect(id);

    }
    @ApiOperation(value = "修改用户信息",notes ="<span style='color:red;'>生犯贪嗔痴戾疑，死受鞭答斧灼烹：</span>&nbsp;枫糖的家" )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "ID",required = true),
            @ApiImplicitParam(name = "name",value = "用户姓名",required = true),
            @ApiImplicitParam(name = "sex",value = "用户性别",required = false)
    })
    @PutMapping("/upDate")
    public R upDate( Luo luo){
        System.out.println("11111");
        return LuoService.upDate(luo);
    }

}
